<!--
 * @Author: wwssaabb
 * @Date: 2021-07-19 11:44:09
 * @LastEditTime: 2021-07-19 11:47:01
 * @FilePath: \demo\react_demo\demo\base_demo\jsx语法规则.html
-->

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="test">

  </div>

  <script type="text/javascript" src="../js/react.development.js" ></script>
  <script type="text/javascript" src="../js/react-dom.development.js" ></script>
  <script type="text/javascript" src="../js/babel.min.js" ></script>
  <script type="text/babel">  /* JSX 语法用babel转换 */
    const dom=(
      <h2 id="title">
        <span>Hello React</span>  
      </h2>
    )
    ReactDOM.render(dom,document.getElementById('test'))

    /* 
      JSX 语法规则
      1.定义虚拟DOM时不需要写冒号
      2.标签中混入js表达式要用{}
      3.样式的类名指定要用className
      4.内联样式要用style={{key:value}}的形式来写
      5.虚拟dom只有一个根标签
      6.标签必须闭合
      7.标签首字母
        （1）若小写字母开头，则将标签转为html标签中同名元素，若无同名元素则报错
        （2）若大写字母开头，react就去渲染对应的组件，如果组件未定义则报错
    */
  </script>
</body>
</html>